<!DOCTYPE html>

<html>



<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">

    <title>商城</title>

    <link rel="stylesheet" href="/static/index/css/goods_index.css" />

</head>



<body>

    <!--判断会员卡是否有钱  与是否设置支付密码-->

    {if ($user.user_card.money)}

    <input type="hidden" name="user_card" value="{$user.user_card.money}" /> {else/}

    <input type="hidden" name="user_card" value="0" /> {/if}

    <!--是否设置支付密码-->

    {if ($user.user_card.pay_password)}

    <input type="hidden" name="pay_password" value="1" /> {else/}

    <input type="hidden" name="pay_password" value="0" /> {/if}

    <!-- hidden -->

    <!--header-->

    <header>

        <img src="https://static.zhihuiyouzhan.com.cn/static/styles/index/images/nongfushangquan.png" class="nongfu_img">

    </header>

    <!--/header-->

    <!--article-->

    <article class="mainwrap">

        <!--left-->

        <div class="navwrap">

            <ul>

            </ul>

        </div>

        <!-- /left -->

        <!--right-->

        <div class="goodswrap">

            <!--当前商品类别浮动框-->

            <h4>

                <span>&nbsp;</span>

            </h4>

            <div class="wrapper">

                <ul class="content">



                </ul>

            </div>

        </div>

        <!-- /right -->

    </article>

    <!--/article-->

    <!-- footer -->

    <footer class="footer">

        <input type="hidden" id="token" value="{$token}" />

        <div class="deal-detail">

            <img src="https://static.zhihuiyouzhan.com.cn/static/styles/index/images/dingdan.png">

            <p>交易详情</p>

            <dl id="nums">0</dl>

        </div>

        <div class="paynow">

            <a>立即支付&nbsp;

                <span>¥</span>

                <span>0</span>

            </a>

        </div>

    </footer>

    <!-- /footer -->



    <!--交易详情-->

    <footer class="deal-detail-con tankuang">

        <div class="car">

            <div class="car-header">

                <a href="javascript:;">交易详情</a>

            </div>

            <div class="car-con editgoods">

                <div style="height: 4rem;line-height: 4rem;text-align: center;">空空如也~</div>

            </div>

        </div>

    </footer>



    <!--立即支付-->

    <footer class="paynow-con tankuang">

        <!--支付主页面-->

        <div class="payMain">

            <div class="payHead">

                <a href="javascript:;">付款详情</a>

                <!--<a href="javascript:;" class="picker-guanbi" style="position: absolute; right: 1.3rem;">关闭</a>-->

            </div>

            <div class="cell">

                <dl class="">

                    <dd>收款油站</dd>

                    <dd>{$merchant.merchant_name}</dd>

                    <!--<dd>123</dd>-->

                </dl>

                <dl class="" id="xuanyouhuiquan">

                    <dd>选择优惠券</dd>

                    <dd class="youhuiquanXianshi">暂无可用优惠券</dd>

                    <dd>

                        <span class="u-icon-arr"></span>

                    </dd>

                </dl>

                <dl class="" id="fukuanfangshi">

                    <dd>付款方式</dd>

                    <dd class="fanshi_box">会员卡支付</dd>

                    <dd>

                        <span class="u-icon-arr"></span>

                    </dd>

                </dl>

            </div>

            <input type="hidden" id="pay_true" value="0" />

            <input type="hidden" id="order_id" value="" />

            <div id="zhifuanniu">确认支付&nbsp;¥

                <span class="pay_true">0</span>

            </div>

        </div>

        <!--支付选择-->

        <div class="payChose">

            <input type="hidden" id="pay_method" value="" />

            <!--选择优惠券-->

            <div class="discount">

                <div class="payHead gengduoHead">

                    <a href="javascript:;">选择优惠券</a>

                    <a href="javascript:;" class="picker-guanbi">

                        <span class="u-icon-left"></span>

                    </a>

                    <input type="hidden" id="coupon_info" data-coupon="0" value="0">

                </div>

                <div class="cell">

                    <dl class="cellbd">

                        <dd>10</dd>

                        <dd>

                            <span class="duihao"></span>

                        </dd>

                    </dl>

                </div>

            </div>



            <!--选择支付方式-->

            <div class="payMethod">

                <div class="payHead gengduoHead">

                    <a href="javascript:;" class="picker-guanbi">

                        <span class="u-icon-left"></span>

                    </a>

                    <a href="javascript:;">支付方式</a>

                </div>



                <div class="cell">

                    <dl id="weixinzhifu">

                        <dd>

                            <img src="https://ww4.sinaimg.cn/large/a15b4afegy1flyqksuxzxj205k05kq2s" class="zhifutuBiao">

                        </dd>

                        <dd>微信支付</dd>

                        <dd>

                            <span class="duihao"></span>

                        </dd>

                    </dl>

                    <input type="hidden" id="is_member" value="{$user.is_member}">

                    <dl id="huiyuankazhifu">

                        <dd>

                            <img src="https://ww4.sinaimg.cn/large/a15b4afegy1flyql6kw98j205k05kjr7" class="zhifutuBiao">

                        </dd>

                        <dd class="isMember">

                            <P>会员卡支付</P>

                            <p style="font-size: 1.24rem;display: none;" id="yuexianshi">余额不足</p>



                            <p style="font-size: 1.24rem;">余额

                                <span style="color: #00CC9A;">¥{$user.user_card.money|default='0.00'}元</span>

                            </p>

                        </dd>

                        <dd class="isMemberNot">

                            <P>会员卡支付</P>

                            <p style="font-size: 1.24rem;" id="yuexianshi">会员卡尚未激活</p>

                        </dd>

                        <dd>

                            <span class="duihao"></span>

                        </dd>

                    </dl>

                </div>

            </div>

        </div>

    </footer>



    <div class="model"></div>

    <!--	<input type="hidden" value="use_$2y$10$LNwAl0dm29P9koXUea/b2uh6wTXWZHVBuUS1efHJur119XjGFgT0G" id="token" />-->

    <!-- 虚拟键盘类结构 -->

    <div class="huiyuankaBox">

        <div class="alert_mask" id="password_root">

            <section class="l_password" showthis="0">

                <section class="l_password_title">请输入会员卡密码</section>

                <section class="l_password_passwordBlcok_fu">

                    <div class="l_password_passwordBlcok">

                        <div>

                            <input type="password" />

                        </div>

                        <div>

                            <input type="password" />

                        </div>

                        <div>

                            <input type="password" />

                        </div>

                        <div>

                            <input type="password" />

                        </div>

                        <div>

                            <input type="password" />

                        </div>

                        <div>

                            <input type="password" />

                        </div>

                    </div>

                </section>

                <section class="l_password_keyboard_fu">

                    <section class="l_password_keyboard_line">

                        <div class="shuziMima">1</div>

                        <div class="shuziMima">2</div>

                        <div class="shuziMima">3</div>

                    </section>

                    <section class="l_password_keyboard_line">

                        <div class="shuziMima">4</div>

                        <div class="shuziMima">5</div>

                        <div class="shuziMima">6</div>

                    </section>

                    <section class="l_password_keyboard_line">

                        <div class="shuziMima">7</div>

                        <div class="shuziMima">8</div>

                        <div class="shuziMima">9</div>

                    </section>

                    <section class="l_password_keyboard_line">

                        <div gray="1"></div>

                        <div class="shuziMima">0</div>

                        <div gray="1" thedelete="1" class="shanchumima"></div>

                    </section>

                </section>

                <section class="l_password_exit"></section>

            </section>

        </div>

    </div>



    <!--商品详情-->

    <section class="info">

        <div class="info-model closeGoods"></div>

        <div class="info-cont editgoods">

        </div>

        <div class="info-close closeGoods">

        </div>

    </section>



</body>

<script type="text/javascript" src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>

<!--滑动插件-->

<script type="text/javascript" src="https://file.zhihuiyouzhan.com.cn/static/plugin/better-scroll/1.12.4/bscroll.min.js"></script>

<script>

    $(function () {

        //设置商品内容的高度

        var z = $(window).height(),

            headimgH = $('.nongfu_img').height(),

            footH = $('.footer').height();

        $(".mainwrap").height(z - headimgH - footH);

        $(".wrapper").height(z - headimgH - footH);



        //会员卡的钱数

        var money = parseFloat($("input[name='user_card']").val()).toFixed(2);



        /* var is_member=1 ;*/

        /*会员卡是否激活*/

        var is_member = $("#is_member").val();



        //获取商品信息和列表信息

        init();

        localStorage.clear();

        //整个商品列表的高度

        var goodsH = [];

        document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法. 

        function subSomething() {

            if (document.readyState == "complete") //当页面加载状态		

                setTimeout(function () {

                    goods_scroll.refresh();/*获取每一个分类的高度,添加到goodsH数组中*/

                    var foodList = document.getElementsByClassName("goodsli");

                    var height = 0;

                    goodsH.push(height);

                    for (var i = 0; i < foodList.length; i++) {

                        var item = foodList[i];

                        height += item.clientHeight;

                        goodsH.push(height);

                    }
                }, 5000);

        }





        //商品列表滑动方法

        var goods_wrapper = document.querySelector('.wrapper');

        var goods_scroll = new BScroll(goods_wrapper, {

            click: true,//开启点击事件

            probeType: 3,

            momentum: true,//添加惯性滑动

            useTransition: false,  // 防止iphone微信滑动卡顿

        })

        goods_scroll.on('scroll', function (e) {

            goods_scroll.refresh();

            var scrolly = e.y;

            for (var j = 0; j < goodsH.length; j++) {

                var height1 = goodsH[j];

                var height2 = goodsH[j + 1];

                //判断当前实时变化的Y值落在哪一个分类的区间，改变那个区间的样式，修改当前分类浮动框的值，并且执行图片懒加载方法；

                if (!height2 || (Math.abs(scrolly) >= height1 && Math.abs(scrolly) < height2)) {

                    $('.navwrap ul li').removeClass('active');

                    $('.navwrap ul li').eq(j).addClass('active');

                    $(".goodswrap>h4>span").html("&nbsp" + $('.navwrap ul li').eq(j)[0].innerText);



                    return false;

                }

            }

        })

        //获取商品信息和列表信息

        function init() {

            // 获取所有分类商品以及数据   

            $.post('{$Think.API_DOMAIN}/index.php/goods/index/getGoodsList', { 'token': $("#token").val() }, function (msg) {

                /*  $.post('https://api-develop.zhihuiyouzhan.com.cn/index.php/goods/index/getGoodsList',{'token':$("#token").val()},function(msg){*/

                if (msg.state == 0) {

                    showModal({
                        content: msg.msg,

                        showCancel: false

                    });

                } else {

                    //初始化商品分类

                    var nav_html = "";

                    //初始化商品分类列表

                    var html = "";

                    if (eval(msg.data).length) {

                        $(".goodswrap>h4>span").html("&nbsp" + msg.data[0].name);



                        $.each(msg.data, function (i, item) {

                            nav_html += '<li data-id="' + item.cateid + '" href="' + item.cateid + '"><span>' + item.name + '</span></li>';

                            var goods_num = $("#num" + item.goods_id).html() ? $("#num" + item.goods_id).html() : 0;

                            html += '<li id="' + item.cateid + '" class="goodsli"><h3><span style="border-left: 2px solid #00cc9e; margin-left: .5rem;">&nbsp;' + item.name + '</span></h3>';

                            if (item.goods.length) {

                                for (var j = 0; j < item.goods.length; j++) {

                                    html += '<div class="goods clearfix">';

                                    html += '<div class="list_img" style="background-image:url(' + item.goods[j].cover_image + ');background-size: cover;" data-img="' + item.goods[j].cover_image + '"></div>';

                                    html += '<div class="goods-info">';

                                    html += '<dl><dt>' + item.goods[j].goods_name + '</dt>';

                                    html += '<dd name="sales">月售' + item.goods[j].sales + '单</dd>';

                                    html += '<dd name="price">￥<span>' + item.goods[j].price + '</span></dd>';

                                    html += '<dd class="goods-button">';

                                    html += '<input type="hidden" name="goods_id" value="' + item.goods[j].goods_id + '">';

                                    html += '<input type="hidden" name="single_price' + item.goods[j].goods_id + '" value="' + item.goods[j].price + '">';

                                    html += '<input type="hidden" name="describe" value="' + item.goods[j].describe + '">';

                                    html += '<input type="hidden" name="content" value="' + item.goods[j].content + '">';

                                    html += '<div  class="deleteicon-a"><span class="deleteicon" style="position:"></span></div><span class="num' + item.goods[j].goods_id + '">' + goods_num + '</span><a class="addicon-a"><span class="addicon"></span></a></dd></dl></div></div>';

                                }

                            } else {

                                html += '<div class="balishui2" style="text-align: center; font-size: 1.3rem; padding: 1.5rem 0;height:4rem; line-height:4rem;">此分类暂无商品</div>';

                            }

                            html += '</li>';

                        });

                    }

                    var u = navigator.userAgent;

                    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端

                    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端





                    if (isiOS) {

                        $('.navwrap>ul').html(nav_html);

                        $('.content').append(html + '<div style="height: 150px;"></div>');



                    } else {

                        $('.navwrap>ul').html(nav_html);

                        $('.content').html(html);

                    }



                    //默认第一个分类

                    $(".navwrap>ul> li").eq(0).addClass("active");



                    /*获取每一个分类的高度,添加到goodsH数组中*/

					/*var foodList = document.getElementsByClassName("goodsli");

					var height = 0;

					goodsH.push(height);

					for (var i = 0; i < foodList.length; i++) {

						var item = foodList[i];

						height += item.clientHeight;

						goodsH.push(height);

					}*/





                    //添加商品分类点击方法

                    $(".navwrap >ul >li").on('click', function (e) {

                        var i = $(this).index('.navwrap ul li');

                        selectMenu(i);

                    })

                }

            });

        }

        /*商品分类点击方法*/

        function selectMenu(index, event) {

            var foodList = document.getElementsByClassName("goodsli");

            var el = foodList[index];

            goods_scroll.scrollToElement(el, 300);

        }





        //分类距离底部时上移

        var nav_slide = function (li) {

            var scrolltop = $(li).offset().top;

            if ((scrolltop > z / 3 * 2)) {

                var lis = $(li).prevAll();

                var lis_height = 0;

                if (lis.length > 0) {

                    for (var i = 0; i < lis.length; i++) {

                        lis_height += $(lis[i]).get(0).getBoundingClientRect().height;

                    }

                }

                $(".navwrap>ul").animate({ 'scrollTop': lis_height }, 300, function () { });

            }

        }



        //点击添加商品

        $(".content").on('click', '.addicon-a', function (event) {

            event.stopPropagation();



            /*如果添加购物车成功*/

            if (addGoods(this)) {

                //添加购物车小球运动动画元素

                var $pointDiv = $('<div id="pointDivs">').appendTo('body');

                for (var i = 0; i < 5; i++) {

                    $('<div class="point-outer point-pre"><div class="point-inner"/></div>').appendTo($pointDiv);

                }

                //小球运动动画

                var startOffset = $(this).offset();

                var endTop = $(window).outerHeight() - footH,

                    endLeft = 60,

                    left = startOffset.left,

                    top = startOffset.top;

                var outer = $('#pointDivs .point-pre').first().removeClass("point-pre").css({ left: left + 'px', top: top + 'px' });

                var inner = outer.find(".point-inner");

                setTimeout(function () {

                    outer[0].style.webkitTransform = 'translate3d(0,' + (endTop - top) + 'px,0)';

                    inner[0].style.webkitTransform = 'translate3d(' + (endLeft - left) + 'px,0,0)';

                    setTimeout(function () {

                        outer.removeAttr("style").addClass("point-pre");

                        inner.removeAttr("style");

                    }, 500);

                    //这里的延迟值和小球的运动时间相关

                }, 1);

            }



        });

        //交易详情，商品详情弹窗添加商品

        $(".editgoods").on('click', '.addicon-a', function (event) {

            event.stopPropagation();

            addGoods(this);

        })

        //点击减少商品

        $(".wrapper").on('click', '.deleteicon-a', function (event) {

            event.stopPropagation();

            deleteGoods(this);

            return false;

        })

        //交易详情里面点击删除

        $(".car-con").on('click', '.deleteicon-a', function (event) {

            event.stopPropagation();

            deleteGoods(this);

        })



        //点击交易详情,显示详情

        $(".deal-detail").click(function () {

            $(".tankuang:not(.deal-detail-con)").slideUp();

            $(".deal-detail-con").slideToggle();

            $('.model').toggle();

        })

        //点击模态框，关闭交易详情

        $('.model').click(function () {

            var left = $(".paynow-con").css("marginLeft");

            if (left != "0px") { $(".paynow-con").animate({ marginLeft: 0 }, 10); }

            $(".tankuang").slideUp();

            $('.model').hide();

        })

        //点击立即支付，显示订单信息         

        $(".paynow").click(function () {

            var html = '';

            $.ajax({

                url: "{$Think.API_DOMAIN}/index.php/user/Coupons/getCoupons",

                /*  url:"https://api-develop.zhihuiyouzhan.com.cn/index.php/user/Coupons/getCoupons",*/

                type: 'GET',

                dataType: 'json',

                data: { 'type': 2, 'token': '{$Think.session.api_token}' },

                /*  data:{'type':2, 'token':$("#token").val()},*/

                success: function (res) {

                    // 判断是否有可用的优惠券   0 是没有

                    if (res.data.count > 0) {

                        html += '<dl class="cellbd"><dd >本次不使用</dd><dd><span class="duihao"></span></dd><input type="hidden" name="goods_coupon" class="coupon_info" data-couponid="0" value="0"></dl>';

                        $.each(res.data.coupons, function (k, v) {

                            html += '<dl class="cellbd">';

                            html += '<dd >' + v.name + '(￥' + v.c_money + ')' + '</dd><dd><span class="duihao"></span></dd>';

                            html += '<input type="hidden" name="goods_coupon" class="coupon_info" data-couponid="' + v.id + '"value="' + v.c_money + '"></dl>';

                        })

                        // 判断是否已经选择优惠券 =》 若已选择优惠券，则会做优惠券面值本地存储

                        if (!localStorage.getItem('c_money')) {

                            $(".youhuiquanXianshi").html(res.data.count + "张可用优惠券")

                        }

                        $(".discount .cell").html(html);

                    } else {

                        $(".discount .cell").html(html);

                        $(".youhuiquanXianshi").html("暂无可用优惠券")

                    }

                    $('.payMethod').hide();

                }

            })

            $(".tankuang:not(.paynow-con)").slideUp();

            $(".paynow-con").slideToggle();

            $('.model').show();

            // 判断支付方式，， 会员卡值高于需要支付的价格，默认使用会员卡支付

            var order_money = parseFloat($("#pay_true").val()).toFixed(2);//订单钱数

            if (is_member == 0) {

                // 未激活       

                $('.isMember').hide();

                $(".isMemberNot").show();

                $('.fanshi_box').text("微信支付");

                $("#pay_method").val(1);

                $(".payMethod .duihao").hide();

                $(".payMethod .duihao").hide().eq(0).show();

            } else {

                //激活

                $('.isMember').show();

                $('.isMemberNot').hide();

                if (money - order_money >= 0) {

                    $('.fanshi_box').text("会员卡支付");

                    $("#pay_method").val(2)

                    $(".payMethod .duihao").hide();

                    $(".payMethod .duihao").hide().eq(1).show();

                } else {

                    $(".payMethod .duihao").hide().eq(0).show();

                    $('.fanshi_box').text("微信支付");

                    $("#pay_method").val(1)

                    $('#yuexianshi').show();//余额u不足           

                }

            }

        })

        //优惠券和支付方式返回

        $('.gengduoHead .picker-guanbi').click(function () {

            $(this).parent().parent().hide();

            $(".paynow-con").animate({ marginLeft: 0 }, 200);

        })



        //点击选择优惠券

        $('#xuanyouhuiquan').click(function () {

            if (parseInt($("#nums").html()) <= 0) {

                showModal({

                    content: "请选择商品",

                    showCancel: false

                });

                return false;

            }

            $(".paynow-con").animate({ marginLeft: "-100%" }, 200);

            $('.payChose').show();

            $('.payMethod').hide();

            $(".discount").show();

        })

        //点击选择支付方式

        $('#fukuanfangshi').click(function () {

            $(".paynow-con").animate({ marginLeft: "-100%" }, 200);

            $('.payChose').show();

            $('.payMethod').show();

            $(".discount").hide();

        })

        //选择优惠券

        $("body").on('click', ".cellbd", function () {

            $(".paynow-con").animate({ marginLeft: 0 }, 200);

            $("#coupon_info").val($(this).children(".coupon_info").val());

            $("#coupon_info").attr("data-coupon", $(this).children(".coupon_info").data("couponid"));

            $(".cellbd").children("dd").children(".duihao").css("display", "none");

            $(this).children("dd").children(".duihao").css("display", "block");

            $('.youhuiquanXianshi').text($(this).find("dd")[0].innerHTML);

            // 选择优惠券是改变价格

            if (!localStorage.getItem('c_money')) {

                localStorage.setItem('c_money', 0.00);

            }

            var pay_true = $(".pay_true").html();

            var money_1 = parseFloat(pay_true) + parseFloat(localStorage.getItem('c_money')) - parseFloat($(this).children(".coupon_info").val())

            money_1 = money_1 >= 0 ? money_1 : 0;

            $("#pay_true").val(money_1.toFixed(2));

            $('.paynow a span:nth-child(2)').text(money_1.toFixed(2));

            $(".pay_true").html(money_1.toFixed(2))

            localStorage.setItem('c_money', $(this).children(".coupon_info").val());

        })

        //点击微信支付

        $("#weixinzhifu").click(function () {

            $('.fanshi_box').text("微信支付");

            $(".payMethod .duihao").hide();

            $("#pay_method").val(1);

            $(this).children().children(".duihao").show();

            $(".paynow-con").animate({ marginLeft: 0 }, 200);

        })

        //点击会员卡支付

        $("#huiyuankazhifu").click(function () {

            var order_money = parseFloat($("#pay_true").val()).toFixed(2);//订单钱数

            if (is_member == 1) {

                if (parseFloat(money) >= parseFloat(order_money)) {

                    $('.fanshi_box').text("会员卡支付");

                    $(".payMethod .duihao").hide();

                    $("#pay_method").val(2);

                    $(this).children().children(".duihao").show();

                    $(".paynow-con").animate({ marginLeft: 0 }, 200);

                }

            }

        })

        //立即支付		

        $('#zhifuanniu').click(function () {



            $('.payChose').slideUp();

            $.post("{:url('goods/create_order')}", { 'pay_method': $("#pay_method").val(), "coupon_id": $("#coupon_info").data("coupon") }, function (res) {

                /*  $.post("https://api-develop.zhihuiyouzhan.com.cn/index/goods/creat_order.html",{'pay_method':$("#pay_method").val(),"coupon_id":$("#coupon_info").data("coupon")},function(res){*/

                var res = $.parseJSON(res)

                console.log(res);

                if (res.code == 1) {

                    showModal({

                        content: res.msg,

                        showCancel: false

                    });

                    $('.model').hide();

                    $(".paynow-con").hide();

                    return false;

                }

                $("#order_id").val(res.data);

                // 判断支付方式

                if ($("#pay_method").val() == 2) {

                    // 会员卡支付  =》 判断是否设置支付密码

                    if ($("input[name='pay_password']").val() == 0) {

                        showModal({

                            title: "会员卡支付",

                            content: "没设置支付密码",

                            showCancel: true,

                            cancelText: '取消',

                            confirmText: '设置支付密码',

                            success: function (res) {

                                if (res.confirm) {

                                    location.href = "{:url('index/user/update_pay_password')}";

                                } else {

                                    $(".gengduoshangpingTanchuang,.dingdantanchuang").slideUp();

                                    $("#coupon_id").select("close");

                                    if ($(".dingdantanchuang").css('display') == 'block') {

                                        $('.model').show();

                                        setTimeout(function () {

                                            $('.zhifuBox').slideDown();

                                        }, 400);

                                    } else {

                                        $('.model').toggle();

                                        $('.zhifuBox').slideToggle();

                                    }

                                }

                            }

                        });

                    } else {

                        setTimeout(function () {

                            $(".huiyuankaBox").slideDown();

                        }, 400);

                    }

                } else if ($("#pay_method").val() == 1) {

                    location.href = res.data;

                }

            })

        })



        //点击显示商品详情

        $(document).on('click', '.goods', function () {

            var goods_id = $(this).find("input[name=goods_id]").val(),

                img_src = $(this).find('.list_img').data('img')

            goods_name = $(this).find("dt").text(),

                goods_sales = $(this).find("dd[name=sales]").text(),

                goods_price = $(this).find("dd[name=price]").find("span").text(),

                goods_describe = $(this).find("input[name=describe]").val(),

                goods_content = $(this).find("input[name=content]").val(),

                num = parseInt($(".num" + goods_id).text()) > 0 ? parseInt($(".num" + goods_id).text()) : 0;

            var html = ''

            html += '<div class="aa" style=" height: calc(100% - 33px);  overflow: auto;"><div class="info-img" style="background-image:url(' + img_src + ');height: 0rem;padding-bottom:100%;width: 100%;background-size: cover; background-repeat: no-repeat;background-position: center;"></div>';

            html += '<dl><dt>' + goods_name + '</dt><dd>' + goods_sales + '</dd><dd >' + goods_describe + '</dd>';

            html += '<dd >' + goods_content + '</dd></dl></div>';

            html += '<dl class="ab"><dd>￥' + goods_price + '</dd><dd class="info-edit"><span>加入购物车</span></dd>';

            html += '<dd class="goods-button info-goods-button"><input type="hidden" name="single_price' + goods_id + '" value="' + goods_price + '"><input type="hidden" name="goods_id" value="' + goods_id + '"><a class="deleteicon-a" style="width: 3rem;position: relative; height: 2.5rem;-webkit-tap-highlight-color:transparent;"><span class="deleteicon"></span></a><span class="num' + goods_id + '">' + num + '</span><a class="addicon-a" style="-webkit-tap-highlight-color:transparent;width: 3rem;position: relative; height: 2.5rem;" ><span class="addicon"></span></a></dd></dl>';

            $(".info-cont").append(html);

            if (num > 0) {

                $(".info-edit").hide();

                $(".info-goods-button").css("display", "flex");

            }



            $(".info").show();

            var height = $(".info-cont").height();

            $(".info-cont").css({ top: "50%", left: "50%", transform: "translate(-50%,-50%)", position: "absolute", display: "inline" });

            var bh = $(".info-cont").find(".ab").outerHeight()

            $(".info-cont .aa").css("height", height);

            var ch = (z - footH - height) / 4 + footH - $('.info-close').height() / 2;

            if (ch < bh) {

                ch = bh;

            }

            $(".info-close").css("bottom", ch + "px");

        });

    })

</script>

<script>

    //商品详情页面方法   

    //商品详情加入购物车

    $(document).on('click', '.info-edit', function () {

        //执行一次加入购物车操作

        addGoods($(this).next().find(".addicon-a"));

        $(this).hide();

        $(this).next().css("display", "flex");

    });

    //商品详情关闭

    $(".closeGoods").click(function () {

        $(".info-cont").empty();

        $(".info").hide();

    })

    //商品详情弹窗删除商品

    $(".info-cont").on('click', '.deleteicon-a', function (event) {

        event.stopPropagation();

        var num = $(this).next().text();

        if ((parseInt(num) == 0)) {

            $(".info-cont").empty();

            $(".info").hide();

            return false;

        }

        deleteGoods(this);

    })

</script>

<script>

    //商品详情和商品页公共方法

    //js小数运算

    function accMul(arg1, arg2) {

        var m = 0, s1 = arg1.toString(), s2 = arg2.toString();

        try {

            m += s1.split(".")[1].length

        } catch (e) { }

        try {

            m += s2.split(".")[1].length

        } catch (e) { }

        return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)

    }

    function accAdd(arg1, arg2) {

        var r1, r2, m;

        try {

            r1 = arg1.toString().split(".")[1].length

        } catch (e) { r1 = 0 }

        try {

            r2 = arg2.toString().split(".")[1].length

        } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2))

        return (arg1 * m + arg2 * m) / m

    }

    function accSubtr(arg1, arg2) {



        var r1, r2, m, n;

        try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }



        try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }

        m = Math.pow(10, Math.max(r1, r2));

        //动态控制精度长度		

        n = (r1 >= r2) ? r1 : r2;

        return ((arg1 * m - arg2 * m) / m).toFixed(n);

    }

    // 操作购物车 根据id qa = 0 删除 num个  qa =1 清空  （price：单价）（ type:1 添加 0 删除	）	  

    function edit_cart(goods_id, price, num, type, qa) {

        var status = 0;

        var total = $('.paynow a span:nth-child(2)').text();//当前立即支付金额

        var price_final = accAdd(parseFloat(total), parseFloat(price));

        if (type) {

            var url = "{$Think.API_DOMAIN}/index.php/goods/index/shoppingCart";

            var data = { 'token': $("#token").val(), 'goods_id': goods_id, 'num': num }

        }

        else {

            price_final = accSubtr(parseFloat(total), parseFloat(price)) >= 0 ? accSubtr(parseFloat(total), parseFloat(price)) : 0;

            var url = "{$Think.API_DOMAIN}/index.php/goods/index/delCartGoods"

            var data = { 'token': $("#token").val(), 'goods_id': goods_id, 'num': num, 'qa': qa }

        }

        $.ajax({

            url: url,

            data: data,

            type: 'post',

            async: false,

            global: false,

            dataType: "json",

            success: function (msg) {

                console.log(msg);

                if (msg['code'] != 0) {



                    if (type) {

                        showModal({

                            content: msg['msg'],

                            showCancel: false

                        });

                    }

                    status = 0;

                    return;

                }

                var html = '';

                var tot = 0;

                $.each(msg.data, function (i, item) {

                    if (Number(item.buy_num > 0)) {

                        html += '<dl>';

                        html += '<dt>' + item.goods_name + '</dt>';

                        html += '<dd style="flex:1;text-align:right;margin-right: 8.5rem;">¥' + accMul(item.price, item.buy_num) + '</dd>';

                        html += '<dd class="jiajian-button" >';

                        html += '<input type="hidden" name="single_price' + item.goods_id + '"value="' + item.price + '">';

                        html += '<input type="hidden" name="goods_id" value="' + item.goods_id + '" />  ';

                        html += '<a class="deleteicon-a" style="width: 3rem;position: relative; height: 3rem;-webkit-tap-highlight-color:transparent;"><span class="deleteicon" style="margin: 6px 3px;"></span></a>';

                        html += '<p  id="num' + item.goods_id + '">' + item.buy_num + '</p>';

                        html += '<a  class="addicon-a" style="-webkit-tap-highlight-color:transparent;width: 3rem;position: relative; height: 3rem;"><span class="addicon" style="margin: 6px 3px;" ></span></a>';

                        html += '</dd>';

                        html += '</dl>';

                        tot += Number(item.buy_num);

                    }

                });

                if (tot == 0) {

                    $(".deal-detail-con").hide();

                    $(".model").hide();

                }

                setTimeout(function () {

                    $('#nums').text(tot);

                }, 500);

                //立即支付

                $('.paynow a span:nth-child(2)').text(price_final);

                $(".pay_true").html(price_final);

                $("#pay_true").val(price_final);

                $('.car-con').html(html);

                status = 1;

                return;

            }

        });

        return status;

    }

    // 刷新 || 加载 清空购物车

    edit_cart(0, 0, 0, 0, 1);

    //是否选择优惠券

    function order_change() {

        if ($("#coupon_info").val() > 0) {

            if (confirm("是否重新下订单？")) {

                window.location.href = '';

            }

            return false;

        }

        return true;

    }

    //商品添加

    function addGoods(addButton) {

        var status = 0;

        var num = $(addButton).prev().text();

        var good_id = $(addButton).siblings("input[name='goods_id']").val();

        var price = $(addButton).siblings("input[name='single_price" + good_id + "']").val();

        if (edit_cart(good_id, price, 1, 1, 0)) {

            $(".num" + good_id).text(parseInt(num) + 1);

            status = 1;

        }

        return status;



    }

    //商品删除

    function deleteGoods(deleteButton) {

        // 选择优惠券后，减少商品时判断

        if (!order_change()) {

            return false;

        }

        var num = $(deleteButton).next().text();

        var good_id = $(deleteButton).siblings("input[name='goods_id']").val();

        var price = $(deleteButton).siblings("input[name='single_price" + good_id + "']").val();

        if (parseInt(num) == 0) {

            $(".num" + good_id).text(0);

            return false;

        }

        if (edit_cart(good_id, price, 1, 0, 0))

            $(".num" + good_id).text(parseInt(num) - 1 < 0 ? 0 : (parseInt(num) - 1));

    }

</script>

<script type="text/javascript">

    //输入密码

    aaaa = 0;

    str = '';

    $('.shuziMima').click(function () {

        if (aaaa < 6) {

            var mima = $(this).text();

            str += mima;

            $('.l_password_passwordBlcok input').eq(aaaa).val(mima);

            aaaa++;

            // 输入密码够六位  执行 ajax 支付 验证

            if (aaaa == 6) {

                $('.huiyuankaBox').slideUp();

                $.ajax({

                    type: 'post',

                    url: "{:url('Payment/cardPay')}",

                    dataType: 'json',

                    data: { 'order_id': $("#order_id").val(), "pay_password": str, 'order_type': 2 },

                    success: function (res) {

                        console.log(res);

                        aaaa = 0;

                        $('.l_password_passwordBlcok input').val("");

                        // 完成支付

                        if (res.code == 0) {

                            showModal({

                                content: res.msg,

                                showCancel: false

                            });

                            setTimeout("location.href=''", 1500);

                        }

                        // 其他错误

                        if (res.code != 0) {

                            aaaa = 0;

                            str = '';

                            showModal({

                                content: res.msg,

                                showCancel: false

                            });

                            $('.model').hide();

                            $('.paynow-con').slideToggle();

                        }

                    }

                })



            }

        }

    })

    $('.shanchumima').click(function () {

        if (aaaa > 0) {

            aaaa--;

            $('.l_password_passwordBlcok input').eq(aaaa).val("");

            str = str.slice(0, -1);

        }

    });

    $('.l_password_exit').click(function () {

        $('.huiyuankaBox').slideUp();

        setTimeout(function () {

            $(".zhifuBox").slideDown();

        }, 400);

        aaaa = 0;

        $('.l_password_passwordBlcok input').val("");

    })

</script>

<script>

    /*页面提示*/

    var showModal = function (object) {

        var title = object.title == undefined ? "提示" : object.title;

        var content = object.content;

        var showCancel = object.showCancel == undefined ? false : object.showCancel;

        var cancelText = "取消", confirmText = "确定";

        var success = object.success;

        var fail = object.fail;

        var complete = object.complete;

        var result;

        var cancelText;

        if (!object.cancelText) {

            cancelText = "取消";

        }

        else {

            cancelText = object.cancelText;

        }

        var confirmText;

        if (!object.confirmText) {

            confirmText = "确定";

        }

        try {

            var viewportID = document.getElementById("viewport");

            if (!viewportID) {

                var oMeta = document.createElement('meta');

                oMeta.content = 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0;';

                oMeta.name = 'viewport';

                oMeta.id = 'viewport';

                document.getElementsByTagName('head')[0].appendChild(oMeta);

            }

            $(".xsw_showModa").remove();

            var showModalHtml = "";

            showModalHtml += '<div class="xsw_showModa">'

            showModalHtml += '<div class="xsw_showModaBei" style="position:fixed;width:100%;height:100%;top:0;left:0;background-color:#333;opacity:0.4;z-index: 99999999999999"></div>'

            showModalHtml += '<div class="xsw_modal-data" style="width:220px;  border-radius: 10px;  top: 50%;  left: 50%;  box-shadow: 0 2px 8px #555 ;  background-color: #fff; text-align:center;  z-index: 9999999999999999999999;  position: fixed;">';

            showModalHtml += '<div style="padding: 1rem;border-bottom: 1px solid #3e3e3e3e;text-align: center;font-size: 18px;font-weight: 400">' + title + '</div><br>';

            showModalHtml += '<div style="text-align: center;font-size: 1.3rem;margin-bottom: 30px;padding-bottom: 1rem;color: #7b7b7b;">' + content + ' </div><br>';

            if (showCancel == false) {

                showModalHtml += '<div style="position: absolute;bottom: 5px;"><div class="yesDian" style="width: 110px;display: inline-block;margin-left: 55px;background-color: gold;cursor: pointer;border-radius: 10px;padding: 8px 0;">' + confirmText + '</div></div>'

            }

            else {

                showModalHtml += ' <div style="position: absolute;bottom: 0px;"><div class="noDian" style="width: 110px;display: inline-block;margin-bottom: 0;border-top: 1px solid #00cc9e; background-color: #ffffff;cursor: pointer;border-radius: 0 0 0 10px;padding: 7px 0; color: #00cc9e;">' + cancelText + '</div><div class="yesDian" style="width: 110px;display: inline-block;background-color: #00cc9e;cursor: pointer;border-radius: 0 0 10px 0;color: #fff;padding: 8px 0;">' + confirmText + '</div></div>';

            }

            '></div></div>';

            $("body").append(showModalHtml);

            var outerWidth = -$('.xsw_modal-data').outerHeight() / 2;

            var modal = document.querySelector('.xsw_modal-data');

            modal.style.margin = outerWidth + 'px 0 0 -110px';



            $("body").css({ "position": "relative" });

            $('.noDian').click(function () {

                $("#viewport").remove();

                $(".xsw_showModa").remove();

                result = {

                    cancel: true,

                    showModal: "ok"

                };

                if (success) {

                    success(result);

                }

                if (complete) {

                    complete(result);

                }

            });

            $('.yesDian').click(function () {

                $("#viewport").remove();

                $(".xsw_showModa").remove();

                result = {

                    confirm: true,

                    showModal: "ok"

                };

                if (success) {

                    success(result);

                }

                if (complete) {

                    complete(result);

                }

            });

        }

        catch (e) {

            result = { errMsg: e.message };

            if (fail) {

                fail(result);

            }

            if (complete) {

                complete(result);

            }

        }

    };

</script>



</html>